import React, { useState } from "react";
import './two.scss'
const AddTodo = (props)=> {
  const [form,setForm] = useState({
    title:'',
    date:'',
    // date:new Date(),
    priority:''
  }) 
  //日期
  const changdate=(e)=>{
      console.log(e.target.value);
      setForm({...form,date:e.target.value})
  }
  //标题
  const handleTitle=(e)=>{
    console.log(e.target.value);
    setForm({...form,title:e.target.value})
}
  //优先级
  const handlePriority=(e)=>{
    console.log(e.target.value);
    setForm({...form,priority:e.target.value})
  }
  //添加
  const addList = ()=>{
     console.log(form);
     let {date,title,priority} = form
     props.todolist({date,title,priority})
  }

    return ( 
      <div className="Todo">
        <div>
          <span>日期:</span><input type="text"  placeholder="日期" onChange={changdate}/>
        </div>
        <div>
          <span>标题:</span><input type="text" value={form.title} placeholder="标题" onChange={handleTitle}/>
        </div>
        <div>
          <span>优先级:</span><input type="text" value={form.priority} placeholder="优先级" onChange={handlePriority}/>
        </div>
        <button className="addbtn" onClick={addList}>添加</button>
      </div>
     );
  }
export default AddTodo;